package javacommon.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javacommon.Constant;

public class PropertiesUtil {
	
	/**
	 * @param path :web.xml文件中threadPoolConfigLocation的值;
	 * @throws IOException 
	 */
	public  void setThreadMaxNum(String path) throws IOException{
		InputStream in=this.getClass().getClassLoader().getResourceAsStream(path);
		if(in!=null){
			Properties pro=new Properties();
			try {
				pro.load(in);
				Integer maxPoolSize=Integer.valueOf(pro.getProperty("pool.maxPoolSize").trim());
				Integer queueCapacity=Integer.valueOf(pro.getProperty("pool.queueCapacity").trim());
				int maxValue=maxPoolSize+queueCapacity;
				//得到容错的值
				int errorValue=(int) (maxValue*0.1);
				//得到实际的最大值
				Constant.T_MAX_NUM=maxValue-errorValue;
			} catch (IOException e) {
				throw e;
			}
		}
	}

}
